#include <54func.h>
int main(int argc,char *argv[])
{
    // ./4_client 192.168.187.128 1234
    ARGS_CHECK(argc,3);
    int sockfd = socket(AF_INET,SOCK_STREAM,0);
    ERROR_CHECK(sockfd,-1,"socket");
    struct sockaddr_in addrClient;
    addrClient.sin_family = AF_INET;
    addrClient.sin_port = htons(atoi(argv[2]));//将端口号转换为大端序
    addrClient.sin_addr.s_addr = inet_addr(argv[1]);//将点分十进制ip转换为网络地址
    int ret = connect(sockfd,(struct sockaddr *)&addrClient,sizeof(addrClient));//客户端使用connect来建立和TCP服务端的连接
    ERROR_CHECK(ret,-1,"connect");


    ssize_t sret = send(sockfd,"Hello",5,0);
    ERROR_CHECK(sret,-1,"send");
    char client[4096] = {0};
    sret = recv(sockfd,client,sizeof(client),0);
    ERROR_CHECK(sret,-1,"recv");
    printf("client = %s\n",client);

    return 0;

}
